import request from '@/common/vmeitime-http';

/**
 * @ desc 积分查找房源页 获取热门板块
 * @ params city {steing} 城市ID
 */
export function findHotPlate(cityCode){
    return request.request({
        url: `/product/mall/v6/query/hot?city=${cityCode}`,
    })
}

//总价找房请求房源列表
export function findPriceAPI(url){
    return request.request({
        url
    })
}

//加载站点房源
export function loadStationProducts(url, params){
    return request.request({
        url,
        data: params
    })
}

//加载环线房源
export function loadHuanXianProducts(url, params){
    return request.request({
        url,
        data: params
    })
}

//加载vr房源
export function loadVRProducts(url, params){
    return request.request({
        url,
        data: params
    })
}

//加载视频房源
export function loadVideoProducts(url, params){
    return request.request({
        url,
        data: params
    })
}

//加载认购监测房源
export function loadRengouProducts(url){
    return request.request({
        url
    })
}

//加载所有房源
export function loadAllProducts(url, params){
    return request.request({
        url,
        data: params
    })
}

//找房首页接口
export function findHomeAPI(){
    return request.request({
        url: `/product/mall/section/index`,
    })
}

/**
 * @ desc 获取腾讯的地铁站数据
 * @ params city
 */
export function tencentMetroAPI(cityCode){
    return request.request({
        url: `/product/mall/v6/station/subway?city=${cityCode}`,
    })
}

/**
 * 上海认购详情API
 * productId
 */
export function rengouDetailAPI(productId){
    return request.request({
        url: `/product/mall/v6/gou/${productId}`,
    })
}

/**
 * 订阅快报咨询页面API
 * @param data {Object}
 * @param city {Number} 城市编码
 */
export function duSubNewsAPI(data){
    return request.request({
        url: `/product/mall/v6/subscribe/fast`,
        method: 'post',
        data
    })
}

/**
 * 查询订阅咨询快报页面的状态
 * @param city {Number} 城市编码
 */
export function getSubNewsAPI(cityCode){
    return request.request({
        url: `/product/mall/v6/subscribe/fast?city=${cityCode}`
    })
}

/**
 * 关注/取消关注置业顾问
 * @param data {Object}
 * @param id {Number} 列表id,有参数代表取消
 * @param data.sid {Number} 顾问id
 * @param data.product_id {Number} 楼盘id
 */
export function subscribeAdviser(data){
    return request.request({
        url: `/product/mall/v6/follow`,
        method: 'post',
        data
    })
}

/**
 * 获取关注的置业顾问列表
 * @param poductId {Number} 楼盘ID 不传返回所有顾问
 */
export function subscribeAdviserList(productId=''){
    return request.request({
        url: `/product/mall/v6/follow?product_id=${productId}`
    })
}

/**
 * 认购汇总
 * @param info {Object}
 * @param info.id {Number} 批次ID
 * @param info.cityCode {Number} 城市编码
 * @param info.day {String} 日期
*/
export function rengouAllAPI(info) {
   return request.request({
        url: `/product/mall/v6/pc/simple/${info.id}?city=${info.cityCode}&day=${info.day}`
   })
}

//入市批次获取
export function getPiCiTab(cityCode) {
   return request.request({
     url: `/product/mall/v6/pc?city=${cityCode}`
   })
}

/**
 * 获取入市批次预测/官宣的标题
 */
export function getPiCiTitle(cityCode){
    return request.request({
        url: `/product/mall/v6/pc/current?city=${cityCode}`
    })
}

/**
 * 朋友圈进入小程序前中间页请求楼盘数据
 */
export function pyqOpenBeforeAPI(productId){
    return request.request({
        url: `/product/mall/v6/timeline/${productId}`
    })
}

/**
 * 获取榜单大分类和子分类
 */
export function rankingClassifyAPI(cityCode){
    return request.request({
        url: `/product/mall/v6/query/mio/params?city=${cityCode}`
    })
}

/**
 * 快讯咨询修改内容
 * @param id {Number} 快讯ID
 */
export function newsEditAPI(data){
    return request.request({
        url: `/product/mall/tips/update/${data.id}`,
        method: 'put',
        data
    })
}

/**
 * 快讯咨询创建
 */
export function newsAddAPI(data){
    return request.request({
        url: `/product/mall/tips/create`,
        method: 'post',
        data
    })
}

/**
 * 快讯咨询删除
 * @param id {Number}
 */
export function newsDeleteAPI(id){
    return request.request({
        url: `/product/mall/tips/update/${id}`,
        method: 'delete'
    })
}

/**
 * 获取今日认购的项目汇总
 */
export function todayRenGouProducts(){
    return request.request({
        url: `/product/assist/mall/score/today`,
    })
}

/**
 * 获取开盘批次内即将认购的项目
 * @param {Number} 开盘批次ID
 */
export function piciSoonProducts(id){
    return request.request({
        url: `/product/assist/mall/score/pc/${id}`,
    })
}

/**
 * 获取开盘批次内选房攻略的项目
 * @param pici {String} 开盘批次ID
 * @param city {String} 城市ID
 */
export function piciStrategyAPI({cityCode='', pici=''}){
    return request.request({
        url: `/product/mall/v6/evaluation?city=${cityCode}&pc=${pici}`,
    })
}

/**
 * 获取页面广告数据
 * @param cityCode {Number} 城市code
 * @param key {String} 页面的name，唯一
 * @param productId {Number} 楼盘ID
 */
export function getPageAdAPI({cityCode='310100', key='', productId=''}){
    return request.request({
        url: `/product/ads/mall/request?city=${cityCode}&key=${key}&product=${productId}`,
    })
}

/**
 * 同类推荐广告
 * @param productId {String} 楼盘ID
*/
export function getSimilarAdAPI(productId=''){
    return request.request({
        url: `/product/mall/v6/ad/${productId}`,
    })
}

/**
 * 详情页banner广告
 * @param productId {String} 楼盘ID
*/
export function bannerAdAPI(productId=''){
    return request.request({
        url: `/product/mall/v6/ad/carousel/${productId}`,
    })
}

/**
 * 月份入市项目汇总列表获取或提交订阅板块内的所有楼盘
 * @param methen {String} get/post
 * @param product_list {Array} 需要订阅的楼盘id
*/
export function monthPublishProducts({ method='get', product_list=[] }){
    return request.request({
        url: `/product/mall/v6/month/list`,
        method,
        data: {product_list}
    })
}

/**
 * 根据市请求所有区域编码
 * @param cityCode {String} 城市编码
*/
export function getAreasForCity(cityCode='', type=''){
    return request.request({
        url: `/product/mall/section/params?city=${cityCode}&type=${type}`,
    })
}

/**
 * 根据区域编码请求多边形数据
 * @param areaCode {String} 区域编码
*/
export function getPolygonForArea(areaCode=''){
    return request.request({
        url: `/product/mall/section/points?area=${areaCode}`,
    })
}

/**
 * 根据区域编码获取所有板块和项目
 * @param areaCode {String} 区域编码
*/
export function plateProductsForArea(areaCode=''){
    return request.request({
        url: `/product/mall/section/detail?area=${areaCode}`,
    })
}

/**
 * 获取土拍批次列表
 * @param cityCode {String}
*/
export function tupaiPiCiList(cityCode) {
    return request.request({
      url: `/product/mall/v5/chunk/pc?city=${cityCode}`,
    })
}

/**
 * 获取土拍文章列表
 * @param cityCode {String}
*/
export function tupaiArticleList(cityCode) {
    return request.request({
      url: `/product/mall/v5/chunk/news?city=${cityCode}`,
    })
}

/**
 * 获取批次内土拍列表
 * @param cityCode {String}
 * @param pici {String} 批次id
*/
export function tuPaiListByPiCi(info) {
    return request.request({
      url: `/product/mall/v5/chunk?city=${info.cityCode}&pc=${info.pici}`,
    })
}

 /**
 * 土拍信息详情
 * @param id {Number} 土拍ID
*/
export function tupaiDetailAPI(id) {
    return request.request({
      url: `/product/mall/v5/chunk/${id}`,
    })
}

/**
 * 土拍文章汇总
 * @param {String} url
*/
export function getTupaiArticles(url) {
    return request.request({
      url
    })
}

/**
 * 土拍列表订阅
 * @param cityCode {String}
*/
export function tupaiSubscribe(cityCode) {
    return request.request({
      url: `/product/mall/v5/chunk/subscribe?city=${cityCode}`,
      method: 'post'
    })
}

/**
 * 认购监测列表页内的批次navs
 * @param cityCode {String}
*/
export function rengouPiCiAPI(cityCode) {
    return request.request({
      url: `/product/mall/v6/gou/pc?city=${cityCode}`
    })
}

/**
 * 获取地铁找房三公里内的房源坐标点
 * @param cityCode {String}
 * @param line {String} 线路
*/
export function getProdPointsOfLine({cityCode, line}) {
    return request.request({
      url: `/product/mall/api/map/subway?city=${cityCode}&subway=${line}`
    })
}

/**
 * 获取环线找房内的tabs
 * 
*/
export function getHuanXianTabs() {
    return request.request({
      url: `/product/mall/section/line`
    })
}

/**
 * 开盘日历
 * @param {String} year
 * @param {String} month
 * 
*/
export function getCalendarAPI(info) {
    return request.request({
        url: `/product/mall/v5/pan/calendar?city=${info.city}&year=${info.year}&month=${info.month}`,
    })
}

/**
 * 库存汇总
 * @param {String} url
*/
export function getKuCunAPI(url) {
    return request.request({
      url
    })
}

/**
 * 摇号公示列表
 * @param {String} url
*/
export function getYaoHaoListAPI(url) {
    return request.request({
      url
    })
}

/**
 * 摇号公示详情
 * @param {String} panId 开盘ID
*/
export function getYaoHaoDetailAPI(panId) {
    return request.request({
      url: `/product/mall/v6/pan/yao/${panId}`
    })
}
